package utility;

import java.awt.Color;

import player.Triangle;

import main.Sprite;

public class ContraBullit extends Sprite {

	public ContraBullit(int x, int y, int dx, int dy) {
		super();
		this.x = x;
		this.y = y;
		this.dx = dx;
		this.dy = dy;
		width = 5;
		height = 5;
	}

	public void draw(){
		g.setColor(Color.GRAY);
		this.g.fillRect(this.x, this.y, width, height);        	        
	}
	public void think(){
		x -= dx;
		y -= dy;
		if(x<=0 || x>=1000) {
			die();
		}
		if(y<=0 || y >= 1000) {
			die();
		}
	}

	public boolean doesCollide(Sprite s) {
		int sLeftEdge = s.getX();
		int sRightEdge = s.getX()+ s.getWidth();
		int sTopEdge = s.getY();
		int sBottomEdge = s.getY() + s.getHeight();

		int leftEdge = this.x;
		int rightEdge = this.x + this.width;
		int topEdge = this.y;
		int bottomEdge = this.y + this.height;

		if( sLeftEdge <= rightEdge && 
				sRightEdge >=  leftEdge &&
				sTopEdge <= bottomEdge &&
				sBottomEdge >= topEdge ) {
			if(s instanceof ContraEnemy) {
				die();
				s.die();
			}
			if(s instanceof ContraPlatform) {
				die();
			}
			return true;
		}	
		return false;
	}
}
